/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package db;

//import java.sql.Connection;
import common.DbConnection;
import java.util.ArrayList;

/**
 *
 * @author pelle
 */
public abstract class AbstractDb {
    public DbConnection db = DbConnection.getInstance();
    //public Connection con = db.getDBcon();
    private ArrayList<String> transStmts = new ArrayList<String>();

    public boolean newTransaction() {
       transStmts.clear();
       return true;
    }

    public boolean addStatement(String stmt) {
        return transStmts.add(stmt);
    }

    public int getStatementCount() {
        return transStmts.size();
    }

    public boolean rollbackTransaction() {
        transStmts.clear();
        return true;
    }

    public boolean commitTransaction() {
        boolean result = false;

        if(transStmts.size() > 0) {
            result = db.executeTransaction(transStmts);
        }

        return result;
    }
}
